using Finance.Api.Read.Applications.Commands.台账管理;
using Finance.Api.Read.Dtos;
using Finance.Domain;
using Finance.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Finance.Api.Read.Controllers.台账管理
{
    /// <summary>
    /// 台账管理-Api(读)
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class LedgerController : ControllerBase
    {
        private readonly IMediator mediator;
        private readonly ILogger<LedgerController> logger;

        public LedgerController(IMediator mediator, ILogger<LedgerController> logger)
        {
            this.mediator = mediator;
            this.logger = logger;
        }

        /// <summary>
        /// 保质期分页查询
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<ApiPaging<List<ProductExpiryDto>>>> GetProductExpiryList([FromQuery] ProductExpiryQueryCommand request)
        {
            logger.LogInformation("保质期分页查询");
            return await mediator.Send(request);
        }

        /// <summary>
        /// 库存分页查询
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<ApiPaging<List<ProductInventoryDto>>>> GetProductInventoryList([FromQuery] ProductInventoryQueryCommand request)
        {
            logger.LogInformation("库存分页查询");
            return await mediator.Send(request);
        }

        /// <summary>
        /// 批次分页查询
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<ApiPaging<List<ProductBatchDto>>>> GetProductBatchList([FromQuery] ProductBatchQueryCommand request)
        {
            logger.LogInformation("批次分页查询");
            return await mediator.Send(request);
        }

        /// <summary>
        /// 库存预警分页查询
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<ApiPaging<List<ProductAlertDto>>>> GetProductAlertList([FromQuery] ProductAlertQueryCommand request)
        {
            logger.LogInformation("库存预警分页查询");
            return await mediator.Send(request);
        }

        /// <summary>
        /// 出入库记录分页查询
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<ApiPaging<List<InventoryFlowDto>>>> GetInventoryFlowList([FromQuery] InventoryFlowQueryCommand request)
        {
            logger.LogInformation("出入库记录分页查询");
            return await mediator.Send(request);
        }
    }
} 